import { $v, urlBaseService } from "@/utils/common.js";

// 获取所属区域信息
export function getAreas(data) {
  return new Promise((resolve, reject) => {
    $v.post(
      this,
      urlBaseService + "/area/getAreaTree",
      data,
      (resp) => {
        resolve(resp);
      },
      () => {
        reject();
      },
      {
        loading: false,
      }
    );
  });
}

// 根据字典类型查询字典数据信息, 查询园区业务字典用
export function getMultipleDicts(dictType) {
  return new Promise((resolve, reject) => {
    $v.get(
      this,
      urlBaseService + "/dict/dictDataType/" + dictType,
      {},
      (resp) => {
        resolve(resp);
      },
      () => {
        reject();
      },
      {
        loading: false,
      }
    );
  });
}

// 根据字典类型查询字典数据信息, 查询通用字典用
export function getMultipleDictsBySDK(dictType) {
  return new Promise((resolve, reject) => {
    $v.get(
      this,
      urlBaseService + "/dict/dictDataTypeBySDK/" + dictType,
      {},
      (resp) => {
        resolve(resp);
      },
      () => {
        reject();
      },
      {
        loading: false,
      }
    );
  });
}

// 物联网设备列表
export function getSensorDeviceList() {
  return new Promise((resolve, reject) => {
    $v.post(
      this,
      urlBaseService + "/video/pageIndSensorDevice",
      { pageNum: 1, pageSize: 100 },
      (resp) => {
        resolve(resp);
      },
      () => {
        reject();
      },
      {
        loading: false,
      }
    );
  });
}

// 查询系统用户列表
export function getSystemUserList() {
  return new Promise((resolve, reject) => {
    $v.post(
      this,
      urlBaseService + "/base/system/user/selectUserByTenantId",
      {},
      (resp) => {
        resolve(resp);
      },
      () => {
        reject();
      },
      {
        loading: false,
      }
    );
  });
}

// 查询系统用户树列表
export function getTenantTree() {
  return new Promise((resolve, reject) => {
    $v.post(
      this,
      urlBaseService + "/base/system/tenantDept/getTenantTree",
      {},
      (resp) => {
        resolve(resp);
      },
      () => {
        reject();
      },
      {
        loading: false,
      }
    );
  });
}

// 根据参数类型标识查参数
export function getParamInfo(data) {
  return new Promise((resolve, reject) => {
    $v.post(
      this,
      urlBaseService + "/param/getParamInfo",
      data,
      (resp) => {
        resolve(resp);
      },
      () => {
        reject();
      },
      {
        loading: false,
      }
    );
  });
}

//获取参数配置，通过key获取value
export function getParamValue(dictType) {
  return new Promise((resolve, reject) => {
    $v.get(
      this,
      urlBaseService + "/param/getParamValue/" + dictType,
      {},
      (resp) => {
        resolve(resp);
      },
      () => {
        reject();
      },
      {
        loading: false,
      }
    );
  });
}

/**
 * 获取天气图标
 */
export function getWeatherIcon(weatherText) {
  let icon;
  if (weatherText) {
    if (weatherText.substring(weatherText.length - 1) === "天") {
      weatherText = weatherText.substring(0, weatherText.length - 1);
    }
    const weatherIcon = {
      晴: "icon-qing1",
      夜间晴: "icon-yejianqingtian",
      阴: "icon-yintian",
      多云: "icon-duoyun",
      夜间多云: "icon-yejianduoyun",
      阵雨: "icon-zhenyu",
      小雨: "icon-xiaoyu",
      中雨: "icon-zhongyu",
      大雨: "icon-dayu",
      暴雨: "icon-baoyu",
      雷阵雨: "icon-leizhenyu",
      阵雪: "icon-zhenxue",
      小雪: "icon-xiaoxue",
      中雪: "icon-zhongxue",
      大雪: "icon-daxue",
      暴雪: "icon-baoxue",
      雾: "icon-wu",
      夜间雾: "icon-yejianwu",
      浮尘: "icon-fuchen",
      扬沙: "icon-yangsha",
      沙尘暴: "icon-shachenbao",
      大暴雨: "icon-dabaoyu1",
      特大暴雨: "icon-tedabaoyu1",
      冻雨: "icon-dongyu1",
      大雨转暴雨: "icon-dayuzhuanbaoyu1",
      龙卷风: "icon-longjuanfeng",
      雾霾: "icon-yinmai",
      带冰雹雷阵雨: "icon-daibingbaoleizhenyu",
      小雨转中雨: "icon-xiaoyuzhuanzhongyu1",
      中雨转大雨: "icon-zhongyuzhuandayu1",
      雨夹雪: "icon-yujiaxue1",
      小雪转中雪: "icon-xiaoxuezhuanzhongxue1",
      中雪转大雪: "icon-zhongxuezhuandaxue1",
      台风: "icon-taifeng",
    };
    icon = weatherIcon[weatherText];
    if (!icon) {
      icon = "icon-wushuju"; // 无数据
    }
  } else {
    // eslint-disable-next-line spaced-comment
    icon = "icon-wushuju"; //无数据
  }
  return icon;
}

//读取记忆接口
export function getUserMemoryInfo(query) {
  return new Promise((resolve, reject) => {
    $v.post(
      this,
      urlBaseService + "/video-video/video/getUserMemoryInfo",
      query,
      (resp) => {
        resolve(resp);
      },
      () => {
        reject();
      },
      {
        loading: false,
      }
    );
  });
}

//读取记忆接口
export function uptUserMemoryInfo(query) {
  return new Promise((resolve, reject) => {
    $v.post(
      this,
      urlBaseService + "/video-video/video/uptUserMemoryInfo",
      query,
      (resp) => {
        resolve(resp);
      },
      () => {
        reject();
      },
      {
        loading: false,
      }
    );
  });
}
